import cv2
from config import cfg
cap = cv2.VideoCapture(cfg.VIDEO_PATH)


def capture():
    i = 0
    cnt = 1
    while 1:
        ret, frame = cap.read()
        if not ret:
            print('can not read frame')
            break

        if i % 10 == 0:
            print(f'epoch:{i}\tsave frame')
            cv2.imwrite(cfg.VIDEO2FRAME_PATH + '\\' + str(cnt) + ".jpg", frame)
            cnt += 1
        i += 1
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break


capture()
cap.release()
cv2.destroyAllWindows()
